<template>
  <div class="bg">
    <!-- <van-pull-refresh style="overflow:none;" v-model = 'isLoading' @refresh='onRefresh'> -->
    <div class="box_ref">
      <van-row class="my_top">
        <van-col class="my_top_left">
          <img src="../../assets/m1.png" />
        </van-col>
        <van-col class="my_top_right">
          <p>{{ cellphone }}</p>
          <span>{{ roleLevel | userRoleLevel }}</span>
        </van-col>
      </van-row>
      <div class="my_box">
        <div class="my_box_margin">
          <van-row class="my_cash" type="flex" justify="space-between">
            <van-col class="my_cash_left">
              <div>总资产</div>
              <p @click="gohHandler(10)">{{ summary | amountFilter }}</p>
              <span>可提现：{{ cash | amountFilter }}</span>
            </van-col>
            <van-col @click="gohHandler(8)" class="my_cash_right">
              <div>提现</div>
            </van-col>
          </van-row>
          <van-row type="flex" justify="space-between" class="my_team">
            <van-col>
              <img @click="gohHandler(1)" src="../../assets/m4.png" />
            </van-col>
            <van-col>
              <img v-if="parentUserId == 0" src="../../assets/m5.png" />
              <img @click="gohHandler(2)" v-else src="../../assets/m5.png" />
            </van-col>
          </van-row>
          <van-row class="my_orders">
            <van-row
              class="orders_con"
              @click="gohHandler(3)"
              type="flex"
              justify="space-between"
            >
              <p>我的订单</p>
              <span><img src="../../assets/m3.png" /></span>
            </van-row>
            <van-row
              class="orders_con"
              @click="gohHandler(12)"
              type="flex"
              justify="space-between"
            >
              <p>我的提券</p>
              <span><img src="../../assets/m3.png" /></span>
            </van-row>
            <van-row
              class="orders_con"
              style="position: relative"
              v-if="parentUserFalg"
              @click="gohHandler(4)"
              type="flex"
              justify="space-between"
            >
              <p>网体归属</p>
              <div class="orders_sel">请归属</div>
              <span><img src="../../assets/m3.png" /></span>
            </van-row>
            <van-row
              class="orders_con"
              @click="gohHandler(5)"
              type="flex"
              justify="space-between"
            >
              <p>实名认证</p>
              <span><img src="../../assets/m3.png" /></span>
            </van-row>
            <van-row
              class="orders_con"
              @click="gohHandler(9)"
              type="flex"
              justify="space-between"
            >
              <p>提现绑定</p>
              <span><img src="../../assets/m3.png" /></span>
            </van-row>
            <van-row
              class="orders_con"
              @click="gohHandler(6)"
              type="flex"
              justify="space-between"
            >
              <p>提现明细</p>
              <span><img src="../../assets/m3.png" /></span>
            </van-row>
            <!-- <van-row class="orders_con" @click="gohHandler(11)" type="flex" justify="space-between">
                        <p>转帐</p>
                        <span><img src="../../assets/m3.png" /></span>
                    </van-row> -->
            <van-row
              class="orders_con"
              @click="gohHandler(7)"
              type="flex"
              justify="space-between"
            >
              <p>退出用户</p>
              <span><img src="../../assets/m3.png" /></span>
            </van-row>
          </van-row>
        </div>
      </div>
    </div>
    <!-- </van-pull-refresh> -->
  </div>
</template>
<script>
import { getSummary, getFttuserUserId } from "@/api/api";
export default {
  name: "my",
  data() {
    return {
      uid: weixin.getUserId(),
      summary: 0, //总资产
      cash: 0, //可提现
      cellphone: "",
      roleLevel: "",
      parentUserFalg: false,
      showDialog: false,
      referralCode: 0,
      textUrl: "",
      isLoading: false,
      parentUserId: 0,
      height: "",
    };
  },
  mounted() {
    this.init();
  },
  methods: {
    onRefresh() {
      this.init();
      this.isLoading = false;
    },
    //初始化
    init() {
      getFttuserUserId({ userId: this.uid }).then((res) => {
        if (res.data.code == 200) {
          //未归属
          this.parentUserId = res.data.data.parentUserId;
          if (this.parentUserId === 0) {
            this.parentUserFalg = true;
          }
          let cellphone = res.data.data.cellphone;
          let str = cellphone.substring(0, 3) + "****" + cellphone.substring(7);
          this.cellphone = str;
          this.roleLevel = res.data.data.roleLevel;
          this.referralCode = res.data.data.referralCode;
          this.textUrl =
            location.protocol +
            "//" +
            location.host +
            "/ka-apiZJHBapp-html/register/index.html?referralCode=" +
            this.referralCode;
        } else {
          this.$dialog.alert({
            message: res.data.msg,
          });
        }
      });
      getSummary({ userId: this.uid }).then((res) => {
        if (res.data.code == 200) {
          let data = res.data.data;
          this.summary = data.pinmoney_bal;
          this.cash = data.pinmoney_bal;
        } else {
          this.$dialog.alert({
            message: res.data.msg,
          });
        }
      });
    },
    //弹窗开卡提示
    handlerShowDialog() {
      this.$router.push("/card");
    },
    //跳转
    gohHandler(val) {
      if (val == 1) {
        this.$router.push("/myteam");
      } else if (val == 2) {
        console.log(this.referralCode, this.textUrl);
        window.JS_TROOPS.dealShare(this.referralCode, this.textUrl);
      } else if (val == 3) {
        this.$router.push("/orders");
      } else if (val == 4) {
        this.$router.push("/ascription");
      } else if (val == 5) {
        this.$router.push("/realName");
      } else if (val == 6) {
        this.$router.push("/withdrawalList");
      } else if (val == 7) {
        window.weixin.removeToken();
        if (weixin.isAndroid()) {
          window.JS_TROOPS.dealLoginOut();
        }
        let time = new Date().getTime();

        this.$router.push("/login?time=" + time);
      } else if (val == 8) {
        this.$router.push("/withdrawal");
      } else if (val == 9) {
        this.$router.push("/bndingBank");
      } else if (val == 10) {
        this.$router.push({ name: "list", params: { acctc: "pinmoney" } });
      } else if (val == 11) {
        this.$router.push("/transfer");
      } else if (val == 12) {
        this.$router.push("/MyExaminationGaper");
      }
    },
  },
};
</script>
<style scoped>
p {
  margin: 0;
  padding: 0;
}
.bg {
  background: #f1f3f6;
  position: relative;
  min-height: 100vh;
  height: auto;
}
.box_ref {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
}
.my_orders {
  height: auto;
}
.my_top {
  width: 100%;
  height: 55vw;
  background: url(../../assets/mbg.png);
  background-size: 100%;
}
.my_top_left {
  padding-top: 24.53vw;
  padding-left: 7.2vw;
}
.my_top_left img {
  width: 14.66vw;
  height: 14.66vw;
}
.my_top_right {
  padding-left: 5.3vw;
  padding-top: 26.13vw;
}
.my_top_right p {
  font-size: 4.8vw;
}
.my_top_right span {
  margin-top: 1.3vw;
  line-height: 6.2vw;
  padding-left: 8vw;
  background: url(../../assets/m2.png);
  background-size: 100%;
  text-align: left;
  display: block;
  width: 21.33vw;
  height: 6.2vw;
  font-size: 2.9vw;
  color: #fff;
}
.my_box {
  position: absolute;
  background: #f1f3f6;
  width: 100%;
  top: 44vw;
}
.my_box_margin {
  margin-left: 3%;
  margin-right: 3%;
  padding-bottom: 20vw;
}
.my_cash {
  background: #fff;
  height: 26.66vw;
  border-radius: 1.3vw;
  width: 100%;
}
.my_cash_left {
  margin-top: 4vw;
  margin-left: 4vw;
}
.my_cash_left div {
  font-size: 3.7vw;
}
.my_cash_left p {
  font-size: 5.6vw;
  color: #ff0000;
  padding-top: 2.6vw;
}
.my_cash_left span {
  font-size: 3.2vw;
  display: block;
  padding-top: 2.6vw;
}
.my_cash_right {
  margin-top: 9.3vw;
  margin-right: 4vw;
}
.my_cash_right div {
  width: 24vw;
  height: 8vw;
  line-height: 8vw;
  text-align: center;
  font-size: 3.7vw;
  border: 1px solid #000;
  border-radius: 4vw;
}
.my_team {
  margin-top: 4vw;
}
.my_team img {
  width: 44vw;
  height: 14.66vw;
}

.orders_con {
  background: #fff;
  border-radius: 1.3vw;
  margin-top: 4vw;
  height: 14.66vw;
  font-size: 3.7vw;
}
.orders_con p {
  margin-left: 4vw;
  line-height: 14.66vw;
}
.orders_sel {
  display: block;
  position: absolute;
  top: 4.6vw;
  left: 26.66vw;
  border-radius: 2.6vw;
  font-size: 2.9vw;
  text-align: center;
  width: 15.73vw;
  height: 5.3vw;
  line-height: 5.3vw;
  background: #ff5112;
  color: #fff;
}
.orders_con span {
  margin-right: 4vw;
  margin-top: 5.6vw;
}
.orders_con span img {
  width: 2vw;
  height: 3.6vw;
}
</style>
